package com.dlc.shop.systemtest.api.amount;

import com.alibaba.fastjson.JSON;
import com.dlc.shop.bean.app.dto.UserAddrDto;
import com.dlc.shop.bean.app.param.AddrParam;
import com.dlc.shop.bean.model.RefundAddr;
import com.dlc.shop.systemtest.constants.Constant;
import com.dlc.shop.systemtest.util.HttpUtil;

import java.util.List;

/**
 * @author lanhai
 */
public class AddrApi {
    public static void addAddr(AddrParam addrParam){
        String url = Constant.API_URL + "/p/address";
        HttpUtil.post(url,addrParam);
    }

    public static List<UserAddrDto> dvyList(){
        String url = Constant.API_URL + "/p/address/list";
        List list = HttpUtil.get(url, List.class);
        return JSON.parseArray(JSON.toJSONString(list), UserAddrDto.class);
    }

    public static void deleteDvy(Long addrId){
        String url = Constant.API_URL +"/p/address/deleteAddr/" + addrId;
        HttpUtil.delete(url);
    }

    public static List<RefundAddr> refundAddrList(){
        String url = Constant.SHOP_URL + "/shop/refundAddr/list";
        List list = HttpUtil.get(url, List.class);
        return JSON.parseArray(JSON.toJSONString(list), RefundAddr.class);
    }

    public static void addRefundAddr(RefundAddr refundAddr){
        String url = Constant.SHOP_URL + "/shop/refundAddr";
        HttpUtil.post(url,refundAddr);
    }
}
